﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FortuneHeavenCommon.DataMap;
using System.Data.SqlClient;

namespace FortuneHeavan.Game.DAL
{
    public class NetpayStaDAL : UserDBBase
    {
        public List<RegisterSta> GetUserStatistic(int page, int size, DateTime start, DateTime end, int isMonth)
        {
            DateTime t = DateTime.MinValue;
            if (start == t || end == t)
            {
                return new List<RegisterSta>();
            }
            List<RegisterSta> list = Query<RegisterSta>("Exec dbo.GetNetPayStatistic @startdate,@enddate,@first,@second,@isMonth ",
                 new SqlParameter("@startdate", start), new SqlParameter("@enddate", end),
                new SqlParameter("@first", size * (page - 1) + 1), new SqlParameter("@second", size * page),
                new SqlParameter("@isMonth", isMonth)
                );
            return list;
        }

        public int GetTotalSize(DateTime start, DateTime end, int isMonth)
        {
            DateTime t = DateTime.MinValue;
            if (start == t || end == t)
            {
                return 0;
            }
            if (isMonth == 1)
            {
                if (start > end)
                {
                    return 0;
                }
                else
                {
                    return (end.Year - start.Year) * 12 + end.Month - start.Month;
                }
            }
            else
            {
                if (start > end)
                {
                    return 0;
                }
                else
                {
                    TimeSpan span = end.Date - start.Date;
                    return span.Days + 1;
                }
            }

        }
    }
}
